package io.dcloud.h527baaa6.activity;

import android.content.Context;
import android.content.Intent;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import io.dcloud.h527baaa6.R;
import io.dcloud.h527baaa6.base.BaseActivity;
import io.dcloud.h527baaa6.bean.EventBigShotSayBean;
import io.dcloud.h527baaa6.bean.XmlBean;
import io.dcloud.h527baaa6.utils.PlayUtil;
import io.dcloud.h527baaa6.view.HomeVoiceView;

public class AudioActivity extends BaseActivity {

    @BindView(R.id.home_voice)
    HomeVoiceView mHomeVoice;
    private XmlBean.DataBean.ItemListBean mItemListBean;

    public static void startActivity(Context context, XmlBean.DataBean.ItemListBean bean) {
        Intent intent = new Intent(context, AudioActivity.class);
        intent.putExtra("data", bean);
        context.startActivity(intent);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_audio;
    }

    @Override
    protected int getTitleText() {
        return R.string.audio;
    }

    @Override
    protected void initViewAndData() {
        mItemListBean = (XmlBean.DataBean.ItemListBean) getIntent().getSerializableExtra("data");
        mToobarTitleView.setTitleText(mItemListBean.getName());
        mHomeVoice.setData(mItemListBean.getContentdat());
    }

    @Override
    protected void onStop() {
        super.onStop();
        EventBus.getDefault().post(new EventBigShotSayBean("close"));//关闭当前界面的音频
        PlayUtil.getIns().stopPlay();
    }


}
